package com.gk.study.utils;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DataUtil {
    public static String setFileName(String fileName){
        if(fileName==null)
            fileName="";
        int index=fileName.lastIndexOf(".");
        if(index>=0)
            fileName=fileName.substring(index + 1);
        else fileName="";
        fileName=DataUtil.toString(new Date(),"yyyyMMddHHmmss")+"."+fileName;
        return fileName;
    }
    public static String toString(Date str, String format){
        if(str==null)
            return null;
        SimpleDateFormat s=new SimpleDateFormat(format);
        ParsePosition pos = new ParsePosition(0);
        String date=s.format(str);
        return date;
    }
}
